
package xj.lang; 

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class JavaReservedWords { 

  protected static final int NUMBER_OF_RESERVEDWORDS = 46;

  public static final int RESERVEDWORD_ABSTRACT = 0;
  public static final int RESERVEDWORD_BOOLEAN = 1;
  public static final int RESERVEDWORD_BREAK = 2;
  public static final int RESERVEDWORD_BYTE = 3;
  public static final int RESERVEDWORD_CASE = 4;
  public static final int RESERVEDWORD_CATCH = 5;
  public static final int RESERVEDWORD_CHAR = 6;
  public static final int RESERVEDWORD_CLASS = 7;
  public static final int RESERVEDWORD_CONST = 8;
  public static final int RESERVEDWORD_CONTINUE = 9;
  public static final int RESERVEDWORD_DEFAULT = 10;
  public static final int RESERVEDWORD_DO = 11;
  public static final int RESERVEDWORD_DOUBLE = 12;
  public static final int RESERVEDWORD_ELSE = 13;
  public static final int RESERVEDWORD_EXTENDS = 14;
  public static final int RESERVEDWORD_FINAL = 15;
  public static final int RESERVEDWORD_FINALLY = 16;
  public static final int RESERVEDWORD_FLOAT = 27;
  public static final int RESERVEDWORD_FOR = 18;
  public static final int RESERVEDWORD_GOTO = 19;
  public static final int RESERVEDWORD_IF = 20;
  public static final int RESERVEDWORD_IMPLEMENTS = 21;
  public static final int RESERVEDWORD_IMPORT = 22;
  public static final int RESERVEDWORD_INSTANCEOF = 23;
  public static final int RESERVEDWORD_INT = 24;
  public static final int RESERVEDWORD_INTERFACE = 25;
  public static final int RESERVEDWORD_LONG = 26;
  public static final int RESERVEDWORD_NATIVE = 27;
  public static final int RESERVEDWORD_NEW = 28;
  public static final int RESERVEDWORD_PACKAGE = 29;
  public static final int RESERVEDWORD_PRIVATE = 30;
  public static final int RESERVEDWORD_PROTECTED = 31;
  public static final int RESERVEDWORD_PUBLIC = 32;
  public static final int RESERVEDWORD_RETURN = 33;
  public static final int RESERVEDWORD_SHORT = 34;
  public static final int RESERVEDWORD_STATIC = 35;
  public static final int RESERVEDWORD_SUPER = 36;
  public static final int RESERVEDWORD_SWITCH = 37;
  public static final int RESERVEDWORD_SYNCHRONIZED = 38;
  public static final int RESERVEDWORD_THIS = 39;
  public static final int RESERVEDWORD_THROW = 40;
  public static final int RESERVEDWORD_THROWS = 41;
  public static final int RESERVEDWORD_TRANSIENT = 42;
  public static final int RESERVEDWORD_TRY = 43;
  public static final int RESERVEDWORD_VOID = 44;
  public static final int RESERVEDWORD_VOLATILE = 45;
  public static final int RESERVEDWORD_WHILE = 46;

  public static boolean isReservedWord(String s) { 
    if (s != null && 
  reservedWords.contains(s)) { 
      return true;
    }
    return false; 
  }

  public static int getReservedWordId(String s) { 
    if (s != null) { 
      Object o = reservedWordMap.get(s);
      if (o != null) {
  return ((Integer) o).intValue();
      }
    }
    return -1; 
  }

  public static boolean isModifier(String s) { 
    if (s != null && 
  modifiers.contains(s)) { 
      return true;
    }
    return false; 
  }

  public static boolean isConstant(String s) { 
    if (s != null && 
  constants.contains(s)) { 
      return true;
    }
    return false; 
  }

  public static boolean isTypeName(String s) { 
    if (s != null && 
  typeNames.contains(s)) { 
      return true;
    }
    return false; 
  }

  static protected Map reservedWordMap = new HashMap(); 

  static protected Set reservedWords = new HashSet(); 
  static protected Set modifiers = new HashSet(); 
  static protected Set typeNames = new HashSet(); 
  static protected Set constants = new HashSet(); 

  static {
    constants.add("null");
    constants.add("true");
    constants.add("false");

    modifiers.add("abstract");
    modifiers.add("const");
    modifiers.add("final");
    modifiers.add("native");
    modifiers.add("private");
    modifiers.add("protected");
    modifiers.add("public");
    modifiers.add("static");
    modifiers.add("synchronized");
    modifiers.add("transient");
    modifiers.add("volatile");

    typeNames.add("boolean");
    typeNames.add("byte");
    typeNames.add("char");
    typeNames.add("double");
    typeNames.add("float");
    typeNames.add("int");
    typeNames.add("long");
    typeNames.add("short");
    typeNames.add("void");

    reservedWords.add("break");
    reservedWords.add("case");
    reservedWords.add("catch");
    reservedWords.add("class");
    reservedWords.add("continue");
    reservedWords.add("default");
    reservedWords.add("do");
    reservedWords.add("else");
    reservedWords.add("extends");
    reservedWords.add("finally");
    reservedWords.add("for");
    reservedWords.add("goto");
    reservedWords.add("if");
    reservedWords.add("implements");
    reservedWords.add("import");
    reservedWords.add("instanceof");
    reservedWords.add("interface");
    reservedWords.add("new");
    reservedWords.add("package");
    reservedWords.add("return");
    reservedWords.add("super");
    reservedWords.add("switch");
    reservedWords.add("this");
    reservedWords.add("throw");
    reservedWords.add("throws");
    reservedWords.add("try");
    reservedWords.add("while");

    reservedWordMap.put("abstract", new Integer(RESERVEDWORD_ABSTRACT));
    reservedWordMap.put("boolean", new Integer(RESERVEDWORD_BOOLEAN));
    reservedWordMap.put("break", new Integer(RESERVEDWORD_BREAK));
    reservedWordMap.put("byte", new Integer(RESERVEDWORD_BYTE));
    reservedWordMap.put("case", new Integer(RESERVEDWORD_CASE));
    reservedWordMap.put("catch", new Integer(RESERVEDWORD_CATCH));
    reservedWordMap.put("char", new Integer(RESERVEDWORD_CHAR));
    reservedWordMap.put("class", new Integer(RESERVEDWORD_CLASS));
    reservedWordMap.put("const", new Integer(RESERVEDWORD_CONST));
    reservedWordMap.put("continue", new Integer(RESERVEDWORD_CONTINUE));
    reservedWordMap.put("default", new Integer(RESERVEDWORD_DEFAULT));
    reservedWordMap.put("do", new Integer(RESERVEDWORD_DO));
    reservedWordMap.put("double", new Integer(RESERVEDWORD_DOUBLE));
    reservedWordMap.put("else", new Integer(RESERVEDWORD_ELSE));
    reservedWordMap.put("extends", new Integer(RESERVEDWORD_EXTENDS));
    reservedWordMap.put("final", new Integer(RESERVEDWORD_FINAL));
    reservedWordMap.put("finally", new Integer(RESERVEDWORD_FINALLY));
    reservedWordMap.put("float", new Integer(RESERVEDWORD_FLOAT));
    reservedWordMap.put("for", new Integer(RESERVEDWORD_FOR));
    reservedWordMap.put("goto", new Integer(RESERVEDWORD_GOTO));
    reservedWordMap.put("if", new Integer(RESERVEDWORD_IF));
    reservedWordMap.put("implements", new Integer(RESERVEDWORD_IMPLEMENTS));
    reservedWordMap.put("import", new Integer(RESERVEDWORD_IMPORT));
    reservedWordMap.put("instanceof", new Integer(RESERVEDWORD_INSTANCEOF));
    reservedWordMap.put("int", new Integer(RESERVEDWORD_INT));
    reservedWordMap.put("interface", new Integer(RESERVEDWORD_INTERFACE));
    reservedWordMap.put("long", new Integer(RESERVEDWORD_LONG));
    reservedWordMap.put("native", new Integer(RESERVEDWORD_NATIVE));
    reservedWordMap.put("new", new Integer(RESERVEDWORD_NEW));
    reservedWordMap.put("package", new Integer(RESERVEDWORD_PACKAGE));
    reservedWordMap.put("private", new Integer(RESERVEDWORD_PRIVATE));
    reservedWordMap.put("protected", new Integer(RESERVEDWORD_PROTECTED));
    reservedWordMap.put("public", new Integer(RESERVEDWORD_PUBLIC));
    reservedWordMap.put("return", new Integer(RESERVEDWORD_RETURN));
    reservedWordMap.put("short", new Integer(RESERVEDWORD_SHORT));
    reservedWordMap.put("static", new Integer(RESERVEDWORD_STATIC));
    reservedWordMap.put("super", new Integer(RESERVEDWORD_SUPER));
    reservedWordMap.put("switch", new Integer(RESERVEDWORD_SWITCH));
    reservedWordMap.put("synchronized", new Integer(RESERVEDWORD_SYNCHRONIZED));
    reservedWordMap.put("this", new Integer(RESERVEDWORD_THIS));
    reservedWordMap.put("throw", new Integer(RESERVEDWORD_THROW));
    reservedWordMap.put("throws", new Integer(RESERVEDWORD_THROWS));
    reservedWordMap.put("transient", new Integer(RESERVEDWORD_TRANSIENT));
    reservedWordMap.put("try", new Integer(RESERVEDWORD_TRY));
    reservedWordMap.put("void", new Integer(RESERVEDWORD_VOID));
    reservedWordMap.put("volatile", new Integer(RESERVEDWORD_VOLATILE));
    reservedWordMap.put("while", new Integer(RESERVEDWORD_WHILE));
  }



} 
